<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/swiper.css">
    <script src="js/vue.js"></script>
    <script src="js/swiper.js"></script>
    <style>
        .box {
            width: 800px;
            height: 300px;
            background-color: yellow;
            margin: auto;
        }
    </style>
</head>

<body>
    <div id="box">
        <!-- 基本结构 -->
        <div class="swiper-container box">
            <div class="swiper-wrapper">
                <div class="swiper-slide" v-for="item in dataList">{{item}}</div>
            </div>

            <div class="swiper-button-next"></div>
            <div class="swiper-button-prev"></div>
        </div>
    </div>
    <script>
        new Vue({
            el: "#box",
            data: {
                dataList: []
            },
            created() { //初始化动态加载数据
                var _this = this;
                setTimeout(function() {
                    _this.dataList = ["首页", "商品", "详情", "购物车", "用户中心"];

                }, 2000)
            },
            updated() { //当DOM更新后初始化Swiper
                new Swiper(".box", {
                    navigation: {
                        nextEl: '.swiper-button-next',
                        prevEl: '.swiper-button-prev',
                    }
                })
            }
        })
    </script>
</body>

</html>